﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Lavka.Models;

namespace Lavka.Core
{
    public class ParametersHelper
    {
        static LavkaDbEntities context = new LavkaDbEntities();

        public static List<Parameters> GetParameters()
        {
            return context.Parameters.ToList();
        }
        public static List<Parameters> GetParametersByCategoryId(int? categoryId)
        {
            return context.Parameters.Where(p => p.CategoryId == categoryId).ToList();
        }
        public static int DeleteParameters(int productId)
        {
            foreach (ParametersValues p in context.ParametersValues.Where(pr => pr.ProductId == productId))
            {
                context.ParametersValues.DeleteObject(p);
            }
            return context.SaveChanges();
        }
    }
}